#ifndef DockFocusControllerH
#define DockFocusControllerH
//============================================================================
/// \file   DockFocusController.h
/// \author Uwe Kindler
/// \date   05.06.2020
/// \brief  Declaration of CDockFocusController class
//============================================================================

//============================================================================
//                                   INCLUDES
//============================================================================
#include <QObject>
#include "ads_globals.h"
#include "DockManager.h"

namespace ads
{
struct DockFocusControllerPrivate;
class CDockManager;
class CFloatingDockContainer;

/**
 * Manages focus styling of dock widgets and handling of focus changes
 */
class ADS_EXPORT CDockFocusController : public QObject
{
	Q_OBJECT
// 私有数据 (pimpl)
private:
    DockFocusControllerPrivate* d;
    friend struct DockFocusControllerPrivate;

// 槽函数
private Q_SLOTS:
    // 应用程序焦点改变时调用
    void onApplicationFocusChanged(QWidget *old, QWidget *now);
    // 焦点窗口改变时调用
    void onFocusWindowChanged(QWindow *focusWindow);
    // Dock区域焦点改变时调用
    void onFocusedDockAreaViewToggled(bool Open);
    // 状态恢复时调用
    void onStateRestored();
    // Dock窗口可见性改变时调用
    void onDockWidgetVisibilityChanged(bool Visible);

public:
    using Super = QObject;

    /**
     * 默认构造函数
     */
    CDockFocusController(CDockManager* DockManager);

    /**
     * 虚析构函数
     */
    virtual ~CDockFocusController();

    /**
     * 如果一个小部件被拖放到容器中，容器需要调用此函数
     */
    void notifyWidgetOrAreaRelocation(QWidget* RelocatedWidget);

    /**
     * 当一个浮动窗口被拖放到新位置时调用此函数。
     * 当调用此函数时，浮动窗口的所有Dock窗口已经插入到新位置中
     */
    void notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget);

    /**
     * 返回在UI中具有焦点样式的Dock窗口，如果没有Dock窗口具有焦点，则返回nullptr
     */
    CDockWidget* focusedDockWidget() const;

    /**
     * 请求为给定的Dock窗口分配的选项卡设置焦点高亮显示
     */
    void setDockWidgetTabFocused(CDockWidgetTab* Tab);

    /**
     * 请求清除Dock窗口的焦点
     */
    void clearDockWidgetFocus(CDockWidget* dockWidget);

    /**
     * 通知Dock焦点控制器，鼠标按下或释放
     */
    void setDockWidgetTabPressed(bool Value);

public Q_SLOTS:
    /**
     * 请求将焦点切换到给定的Dock窗口
     */
    void setDockWidgetFocused(CDockWidget* focusedNow);
}; // class DockFocusController
}
 // namespace ads
//-----------------------------------------------------------------------------
#endif // DockFocusControllerH

